{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Dynamic Process: Robustness to the Initial Poll (C.4)"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-16T11:20:03.222937Z",
"start_time": "2021-02-16T11:20:01.167004Z"
}
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from poisson_approval import *"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-16T11:20:03.228589Z",
"start_time": "2021-02-16T11:20:03.224598Z"
}
},
"outputs": [],
"source": [
"N_SAMPLES = 10000\n",
"N_MAX_EPISODES = 1000"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-16T11:20:03.243548Z",
"start_time": "2021-02-16T11:20:03.229585Z"
}
},
"outputs": [],
"source": [
"inits = {\n",
" 'uniform undominated': 'random_tau_undominated',\n",
" 'expressive': 'fanatic',\n",
"}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Condorcet Consistency"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-16T14:42:35.701243Z",
"start_time": "2021-02-16T11:20:03.244545Z"
}
},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Approval | \n",
" Plurality | \n",
" Anti-plurality | \n",
"
\n",
" \n",
" Distribution of tau^0 | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" uniform undominated | \n",
" 0.999974 | \n",
" 0.8170 | \n",
" 0.489474 | \n",
"
\n",
" \n",
" expressive | \n",
" 0.999990 | \n",
" 0.9681 | \n",
" 0.488994 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Approval Plurality Anti-plurality\n",
"Distribution of tau^0 \n",
"uniform undominated 0.999974 0.8170 0.489474\n",
"expressive 0.999990 0.9681 0.488994"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"table_cond = pd.DataFrame()\n",
"table_cond.index.name = 'Distribution of tau^0'\n",
"for init_name, init in inits.items():\n",
" rand_profile = RandConditional(\n",
" RandProfileHistogramUniform(n_bins=1), \n",
" test=is_condorcet, n_trials_max=None\n",
" )\n",
" results = monte_carlo_fictitious_play(\n",
" factory=rand_profile,\n",
" n_samples=N_SAMPLES,\n",
" n_max_episodes=N_MAX_EPISODES,\n",
" voting_rules=VOTING_RULES,\n",
" init=init,\n",
" monte_carlo_settings=[\n",
" MCS_FREQUENCY_CW_WINS,\n",
" ],\n",
" file_save='sav/init_%s_with_CW.sav' % init_name,\n",
" )\n",
" for voting_rule in VOTING_RULES:\n",
" table_cond.loc[init_name, voting_rule] = float(results[voting_rule]['mean_frequency_cw_wins'])\n",
"table_cond"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Welfare Loss"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"ExecuteTime": {
"end_time": "2021-02-16T19:07:50.719809Z",
"start_time": "2021-02-16T14:42:35.702241Z"
},
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Approval | \n",
" Plurality | \n",
" Anti-plurality | \n",
"
\n",
" \n",
" Distribution of tau^0 | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" uniform undominated | \n",
" 0.006502 | \n",
" 0.030931 | \n",
" 0.099204 | \n",
"
\n",
" \n",
" expressive | \n",
" 0.006553 | \n",
" 0.008550 | \n",
" 0.099098 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Approval Plurality Anti-plurality\n",
"Distribution of tau^0 \n",
"uniform undominated 0.006502 0.030931 0.099204\n",
"expressive 0.006553 0.008550 0.099098"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"table_welfare_loss = pd.DataFrame()\n",
"table_welfare_loss.index.name = 'Distribution of tau^0'\n",
"for init_name, init in inits.items():\n",
" rand_profile = RandProfileHistogramUniform(n_bins=1)\n",
" results = monte_carlo_fictitious_play(\n",
" factory=rand_profile,\n",
" n_samples=N_SAMPLES,\n",
" n_max_episodes=N_MAX_EPISODES,\n",
" voting_rules=VOTING_RULES,\n",
" init=init,\n",
" monte_carlo_settings=[\n",
" MCS_WELFARE_LOSSES,\n",
" ],\n",
" file_save='sav/init_%s.sav' % init_name,\n",
" )\n",
" for voting_rule in VOTING_RULES:\n",
" table_welfare_loss.loc[init_name, voting_rule] = float(\n",
" results[voting_rule]['mean_utilitarian_welfare_loss'])\n",
"table_welfare_loss"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
},
"toc": {
"base_numbering": 1,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": true,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}